package com.example.p04orphanremoval;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

//User是用户的主信息 UserInfo是用户的扩展信息
//一对一关联  user_info表里面有个user_id作为外键
//JPA规定
//    若双向关联 维护关系的是拥有外键的一方 另一方必须是mappedBy
//    若单向关联 直接配置拥有外键的一方既可
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "t_user")
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String name;
    private String email;
    private String sex;
    private String address;

    @OneToOne(mappedBy = "user")
    private UserInfo userInfo;
}
